package by.jabbby.ui.data;

import java.util.Comparator;

import org.jivesoftware.smack.RosterEntry;

import android.os.Parcel;
import android.os.Parcelable;

public class RosterEntryObj implements Parcelable{
	private String name;
	private String user; //jid
	private String status;
	

	
	
	public RosterEntryObj(Parcel in){
		readFromIn(in);
		
	}
	
	public RosterEntryObj(String name, String user, String status){
		this.name = name;
		this.user = user;
		this.status = status;
		
	}
	
	public RosterEntryObj(RosterEntry e){
		if(e!=null){
		this.name = e.getName();
		this.user = e.getUser();
		this.status = (e.getStatus() == null)?null:e.getStatus().toString();
		}
	}
	 public static final Parcelable.Creator<RosterEntryObj> CREATOR = new Parcelable.Creator<RosterEntryObj>() {
	        public RosterEntryObj createFromParcel(Parcel in) {
	            return new RosterEntryObj(in);
	        }

	        public RosterEntryObj[] newArray(int size) {
	            return new RosterEntryObj[size];
	        }
	    };

	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	public void writeToParcel(Parcel dest, int flags) {
		// TODO Auto-generated method stub
		DataParcibleUtil.writeData(this, dest);		
		
	}
	
	public void readFromIn(Parcel in){
		//String tmp = in.readString();
	//	this.setAddress(tmp);
		DataParcibleUtil.fillData(this, in);
		//return null;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}
	
	public static class ComparatorByJID implements Comparator<RosterEntryObj>{

		public int compare(RosterEntryObj o1, RosterEntryObj o2) {
			
			return o1.getUser().compareTo(o2.getUser());
		}
		
	}
	
	
	

}
